package com.example.midprojcampusspringboot.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


/**
 * 自定义的分页参数返回类
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class  TableData {

    private Integer code;
    private String msg;
    private Object rows;
    private Integer total;

    // 返回成功--自定义msg、rows、total
    public static TableData success(String msg,Object rows,Integer total){
        return new TableData(200,msg,rows,total);
    }

    // 返回成功--自定义rows、total
    public static TableData success(Object rows,Integer total){
        return new TableData(200,"操作成功",rows,total);
    }

    // 返回成功--自定义msg、rows
    public static TableData success(String msg, Object rows){ return new TableData(200, msg, rows,null);}

    // 返回失败--自定义msg
    public static TableData error(String msg){
        return new TableData(500,msg,null,null);
    }

}
